package com.wang.controller;


import com.wang.param.ShopQueryParam;
import com.wang.reponse.ShopVo;
import com.wang.result.BaseResponse;
import com.wang.result.ResultUtils;
import com.wang.user.model.Shop;
import com.wang.user.service.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/shop")
@Api(tags = "商铺管理")
public class ShopController {
    @Resource
    private ShopService shopService;

    @GetMapping("/list")
    @ApiOperation(value = "获取所有商铺列表")
    public BaseResponse<List<Shop>> listShop(ShopQueryParam queryParam) {
        return ResultUtils.success(shopService.listShop(queryParam));
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加商铺")
    public BaseResponse<Boolean> add(@RequestBody Shop shop) {
        return ResultUtils.success(shopService.add(shop));
    }

    @GetMapping("/detail/{id}")
    @ApiOperation(value = "获取商铺详情")
    public BaseResponse<ShopVo> getShopById(@PathVariable Long id) {
        return ResultUtils.success(shopService.getShopById(id));
    }

    @PostMapping("/delete/{id}")
    @ApiOperation(value = "删除商铺")
    public BaseResponse<Boolean> deleteShop(@PathVariable Long id) {
        return ResultUtils.success(shopService.deleteShop(id));
    }

    @PostMapping("/update")
    @ApiOperation(value = "更新商铺信息")
    public BaseResponse<Boolean> updateShop(@RequestBody Shop shop) {
        return ResultUtils.success(shopService.updateShop(shop));
    }

}
